package com.groupbuying.store.service.impl;

import com.groupbuying.store.constants.CommonConstants;
import com.groupbuying.store.domain.CompanyQualificationDO;
import com.groupbuying.store.pojo.BaseEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.groupbuying.store.dao.StoreCompanyInfoDao;
import com.groupbuying.store.domain.StoreCompanyInfoDO;
import com.groupbuying.store.service.StoreCompanyInfoService;



@Service
public class StoreCompanyInfoServiceImpl implements StoreCompanyInfoService {
	@Autowired
	private StoreCompanyInfoDao storeCompanyInfoDao;
	
	@Override
	public StoreCompanyInfoDO get(String uuid){
		return storeCompanyInfoDao.get(uuid);
	}
	
	@Override
	public List<StoreCompanyInfoDO> list(Map<String, Object> map){
		return storeCompanyInfoDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return storeCompanyInfoDao.count(map);
	}
	
	@Override
	public int save(StoreCompanyInfoDO storeCompanyInfo){
		return storeCompanyInfoDao.save(storeCompanyInfo);
	}
	
	@Override
	public int update(StoreCompanyInfoDO storeCompanyInfo){
		return storeCompanyInfoDao.update(storeCompanyInfo);
	}
	
	@Override
	public int remove(String uuid){
		return storeCompanyInfoDao.remove(uuid);
	}
	
	@Override
	public int batchRemove(String[] uuids){
		return storeCompanyInfoDao.batchRemove(uuids);
	}

    @Override
    public Map<String, StoreCompanyInfoDO> getByStoreUuids(List<String> storeUuids) {
		Map<String,Object > param = new HashMap<>();
		param.put("delflag",CommonConstants.COMMON_FLAG_UNDEL);
		param.put("storeuuids",storeUuids);
		List <StoreCompanyInfoDO> list = storeCompanyInfoDao.getByStoreUuids(param);
		Map<String,StoreCompanyInfoDO> result = new HashMap<>();
		if(list != null && list.size()>0){
			for(StoreCompanyInfoDO storeCompanyInfo:list){
				result.put(storeCompanyInfo.getStoreuuid(), storeCompanyInfo);
			}
		}
		return result;

    }

	@Override
	public StoreCompanyInfoDO getCompanyInfoByStoreUuid(String storeUuid) {

		Map<String, Object> params = new HashMap<>();
		params.put("delflag", CommonConstants.COMMON_FLAG_UNDEL);
		params.put("storeuuid", storeUuid);
		List<StoreCompanyInfoDO> list = storeCompanyInfoDao.list(params);
		return list != null && list.size() > 0 ? list.get(0) : null;
	}

}
